package com.qiangesoft.bootcodegen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiangesoft.bootcodegen.entity.BcgProject;
import com.qiangesoft.bootcodegen.mapper.BcgProjectMapper;
import com.qiangesoft.bootcodegen.pojo.convert.BcgProjectConvert;
import com.qiangesoft.bootcodegen.pojo.dto.BcgProjectDTO;
import com.qiangesoft.bootcodegen.service.IBcgProjectService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 项目配置 服务实现类
 * </p>
 *
 * @author qiangesoft
 * @date 2024-04-01
 */
@Service
public class BcgProjectServiceImpl extends ServiceImpl<BcgProjectMapper, BcgProject> implements IBcgProjectService {

    @Override
    public BcgProject getProject() {
        LambdaQueryWrapper<BcgProject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.last("limit 1");
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateProject(Long id, BcgProjectDTO projectDTO) {
        BcgProject bcgProject = BcgProjectConvert.INSTANCE.dtoToEntity(projectDTO);
        bcgProject.setId(id);
        baseMapper.updateById(bcgProject);
    }
}
